package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysOauthTokenDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysOauthToken;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysOauthTokenDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    BasicColumn[] selectList = BasicColumn.columnList(tokenId, accountId, clientId, createTime, accessToken, refreshExpiresTime, refreshExpiresIn, refreshToken, deviceName, deviceId, deviceType);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysOauthToken> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysOauthToken> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysOauthTokenResult")
    Optional<TSysOauthToken> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysOauthTokenResult", value = {
        @Result(column="token_id", property="tokenId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR),
        @Result(column="client_id", property="clientId", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="access_token", property="accessToken", jdbcType=JdbcType.CHAR),
        @Result(column="refresh_expires_time", property="refreshExpiresTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="refresh_expires_in", property="refreshExpiresIn", jdbcType=JdbcType.INTEGER),
        @Result(column="refresh_token", property="refreshToken", jdbcType=JdbcType.CHAR),
        @Result(column="device_name", property="deviceName", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_id", property="deviceId", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_type", property="deviceType", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysOauthToken> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int deleteByPrimaryKey(String tokenId_) {
        return delete(c -> 
            c.where(tokenId, isEqualTo(tokenId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int insert(TSysOauthToken record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthToken, c ->
            c.map(tokenId).toProperty("tokenId")
            .map(accountId).toProperty("accountId")
            .map(clientId).toProperty("clientId")
            .map(createTime).toProperty("createTime")
            .map(accessToken).toProperty("accessToken")
            .map(refreshExpiresTime).toProperty("refreshExpiresTime")
            .map(refreshExpiresIn).toProperty("refreshExpiresIn")
            .map(refreshToken).toProperty("refreshToken")
            .map(deviceName).toProperty("deviceName")
            .map(deviceId).toProperty("deviceId")
            .map(deviceType).toProperty("deviceType")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int insertMultiple(Collection<TSysOauthToken> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysOauthToken, c ->
            c.map(tokenId).toProperty("tokenId")
            .map(accountId).toProperty("accountId")
            .map(clientId).toProperty("clientId")
            .map(createTime).toProperty("createTime")
            .map(accessToken).toProperty("accessToken")
            .map(refreshExpiresTime).toProperty("refreshExpiresTime")
            .map(refreshExpiresIn).toProperty("refreshExpiresIn")
            .map(refreshToken).toProperty("refreshToken")
            .map(deviceName).toProperty("deviceName")
            .map(deviceId).toProperty("deviceId")
            .map(deviceType).toProperty("deviceType")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int insertSelective(TSysOauthToken record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthToken, c ->
            c.map(tokenId).toPropertyWhenPresent("tokenId", record::getTokenId)
            .map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(clientId).toPropertyWhenPresent("clientId", record::getClientId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(accessToken).toPropertyWhenPresent("accessToken", record::getAccessToken)
            .map(refreshExpiresTime).toPropertyWhenPresent("refreshExpiresTime", record::getRefreshExpiresTime)
            .map(refreshExpiresIn).toPropertyWhenPresent("refreshExpiresIn", record::getRefreshExpiresIn)
            .map(refreshToken).toPropertyWhenPresent("refreshToken", record::getRefreshToken)
            .map(deviceName).toPropertyWhenPresent("deviceName", record::getDeviceName)
            .map(deviceId).toPropertyWhenPresent("deviceId", record::getDeviceId)
            .map(deviceType).toPropertyWhenPresent("deviceType", record::getDeviceType)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default Optional<TSysOauthToken> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default List<TSysOauthToken> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default List<TSysOauthToken> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default Optional<TSysOauthToken> selectByPrimaryKey(String tokenId_) {
        return selectOne(c ->
            c.where(tokenId, isEqualTo(tokenId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysOauthToken, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysOauthToken record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(tokenId).equalTo(record::getTokenId)
                .set(accountId).equalTo(record::getAccountId)
                .set(clientId).equalTo(record::getClientId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(accessToken).equalTo(record::getAccessToken)
                .set(refreshExpiresTime).equalTo(record::getRefreshExpiresTime)
                .set(refreshExpiresIn).equalTo(record::getRefreshExpiresIn)
                .set(refreshToken).equalTo(record::getRefreshToken)
                .set(deviceName).equalTo(record::getDeviceName)
                .set(deviceId).equalTo(record::getDeviceId)
                .set(deviceType).equalTo(record::getDeviceType);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysOauthToken record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(tokenId).equalToWhenPresent(record::getTokenId)
                .set(accountId).equalToWhenPresent(record::getAccountId)
                .set(clientId).equalToWhenPresent(record::getClientId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(accessToken).equalToWhenPresent(record::getAccessToken)
                .set(refreshExpiresTime).equalToWhenPresent(record::getRefreshExpiresTime)
                .set(refreshExpiresIn).equalToWhenPresent(record::getRefreshExpiresIn)
                .set(refreshToken).equalToWhenPresent(record::getRefreshToken)
                .set(deviceName).equalToWhenPresent(record::getDeviceName)
                .set(deviceId).equalToWhenPresent(record::getDeviceId)
                .set(deviceType).equalToWhenPresent(record::getDeviceType);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int updateByPrimaryKey(TSysOauthToken record) {
        return update(c ->
            c.set(accountId).equalTo(record::getAccountId)
            .set(clientId).equalTo(record::getClientId)
            .set(createTime).equalTo(record::getCreateTime)
            .set(accessToken).equalTo(record::getAccessToken)
            .set(refreshExpiresTime).equalTo(record::getRefreshExpiresTime)
            .set(refreshExpiresIn).equalTo(record::getRefreshExpiresIn)
            .set(refreshToken).equalTo(record::getRefreshToken)
            .set(deviceName).equalTo(record::getDeviceName)
            .set(deviceId).equalTo(record::getDeviceId)
            .set(deviceType).equalTo(record::getDeviceType)
            .where(tokenId, isEqualTo(record::getTokenId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_token")
    default int updateByPrimaryKeySelective(TSysOauthToken record) {
        return update(c ->
            c.set(accountId).equalToWhenPresent(record::getAccountId)
            .set(clientId).equalToWhenPresent(record::getClientId)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(accessToken).equalToWhenPresent(record::getAccessToken)
            .set(refreshExpiresTime).equalToWhenPresent(record::getRefreshExpiresTime)
            .set(refreshExpiresIn).equalToWhenPresent(record::getRefreshExpiresIn)
            .set(refreshToken).equalToWhenPresent(record::getRefreshToken)
            .set(deviceName).equalToWhenPresent(record::getDeviceName)
            .set(deviceId).equalToWhenPresent(record::getDeviceId)
            .set(deviceType).equalToWhenPresent(record::getDeviceType)
            .where(tokenId, isEqualTo(record::getTokenId))
        );
    }
}